package com.michael.retail.sys.biz.service.impl;

import com.michael.retail.sys.api.pojo.entity.OAuth2Client;
import com.michael.retail.sys.biz.service.OAuth2ClientService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;

/**
 * 类功能描述:
 * <pre>
 *   OAuth2ClientService
 * </pre>
 *
 * @author Michael
 * @version 1.0
 * @date 2021/7/5 19:58
 */
@Service
public class OAuth2ClientServiceImpl implements OAuth2ClientService {

    @Override
    public OAuth2Client getById(String id) {

        // TODO 假装从数据库拿的数据
        BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();

        OAuth2Client client = new OAuth2Client();
        client.setClientId(id);
        client.setClientSecret(passwordEncoder.encode("123456"));
        client.setScope("all");
        client.setAuthorizedGrantTypes("password,refresh_token,password_code");
        client.setAccessTokenValidity(1 * 60 * 60);
        client.setRefreshTokenValidity(24 * 60 * 60);

        return client;
    }
}
